package com.roadjava.demo05;

import com.roadjava.Application;
import com.roadjava.Builder;
import com.roadjava.beans.dto.CarDTO;
import com.roadjava.beans.vo.CarVO;
import com.roadjava.convert.demo05.CarConvert05;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class)
public class MapStructTest05 {

    @Test
    public void test() {
        CarDTO carDTO = Builder.buildCarDTO();
        CarVO carVO = CarConvert05.INSTANCE.dto2vo(carDTO);

        System.out.println(carVO);

        CarDTO carDTO2 = new CarDTO();
        carDTO2.setBrand("迈巴赫");

        // 通过 carDTO2 的属性值来更新已存在的 carVO 对象
        CarConvert05.INSTANCE.updateCarVO(carDTO2, carVO);

        System.out.println(carVO);
    }

}